using MicroMsg.Common.Utils;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace MicroMsg.Storage
{
	public class ContentObject : TloXmlItem
	{
		private const string TAG = "TimeLineObject";
		public int nStyle;
		public string strTitle;
		public string strDescription;
		public string strContentUrl;
		public TloAppInfo appInfo;
		public List<TloMedia> mediaList;
		public ContentObject()
		{
		}
		public ContentObject(XElement xelement_0)
		{
			this.parse(xelement_0);
		}
		public bool parse(XElement xelement_0)
		{
			using (IEnumerator<XElement> enumerator = xelement_0.Elements().GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					XElement current = enumerator.get_Current();
					if (!current.get_IsEmpty() || current.get_HasAttributes())
					{
						if (current.get_Name() == "contentStyle")
						{
							this.nStyle = (int)current;
						}
						else
						{
							if (current.get_Name() == "title")
							{
								this.strTitle = (string)current;
							}
							else
							{
								if (current.get_Name() == "description")
								{
									this.strDescription = (string)current;
								}
								else
								{
									if (current.get_Name() == "appInfo")
									{
										if (!TloXmlItem.IsEmpty(current))
										{
											this.appInfo = new TloAppInfo(current);
										}
									}
									else
									{
										if (current.get_Name() == "mediaList")
										{
											this.parseMediaList(current);
										}
										else
										{
											if (current.get_Name() == "contentUrl")
											{
												this.strContentUrl = (string)current;
											}
											else
											{
												Log.smethod_4("TimeLineObject", "unknown constent object tag=" + current.get_Name());
											}
										}
									}
								}
							}
						}
					}
				}
			}
			return true;
		}
		public bool parseMediaList(XElement xelement_0)
		{
			using (IEnumerator<XElement> enumerator = xelement_0.Elements().GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					XElement current = enumerator.get_Current();
					if (!current.get_IsEmpty() && !(current.get_Name() != "media"))
					{
						if (this.mediaList == null)
						{
							this.mediaList = new List<TloMedia>();
						}
						this.mediaList.Add(new TloMedia(current));
					}
				}
			}
			return true;
		}
		public XElement toXElement()
		{
			XElement xElement = new XElement("ContentObject");
			xElement.Add(new XElement("contentStyle", this.nStyle));
			if (this.strTitle != null)
			{
				xElement.Add(new XElement("title", this.strTitle));
			}
			if (this.strDescription != null)
			{
				xElement.Add(new XElement("description", this.strDescription));
			}
			if (this.strContentUrl != null)
			{
				xElement.Add(new XElement("contentUrl", this.strContentUrl));
			}
			if (this.appInfo != null)
			{
				xElement.Add(this.appInfo.toXElement());
			}
			if (this.mediaList != null)
			{
				XElement xElement2 = new XElement("mediaList");
				using (List<TloMedia>.Enumerator enumerator = this.mediaList.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						TloMedia current = enumerator.get_Current();
						xElement2.Add(current.toXElement());
					}
				}
				xElement.Add(xElement2);
			}
			return xElement;
		}
		public override void dump(ref string strInfo)
		{
			base.dump(ref strInfo);
			if (this.mediaList != null)
			{
				using (List<TloMedia>.Enumerator enumerator = this.mediaList.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						TloMedia current = enumerator.get_Current();
						current.dump(ref strInfo);
					}
				}
			}
		}
	}
}
